package com.avecsys.quotemanager.utils;

import java.util.Properties;

import javax.faces.context.FacesContext;

import org.springframework.web.jsf.FacesContextUtils;

public class SystemConfig {

	/**
	 * Method return the value for the given key from the application.properties
	 * file
	 * 
	 * @param key
	 * @return String value
	 */
	public static String getProperty(String key) {
		Properties properties = (Properties) FacesContextUtils
				.getWebApplicationContext(FacesContext.getCurrentInstance())
				.getBean("systemConfig");
		return (String) properties.get(key);
	}

	/**
	 * Method to read a value based on key in resouces_url.properties file
	 * 
	 * @param resourceName
	 * @return resource Value
	 */
	public static String getResourceURL(String resourceName) {
		Properties properties = (Properties) FacesContextUtils
				.getWebApplicationContext(FacesContext.getCurrentInstance())
				.getBean("resourceUrl");
		return (String) properties.get(resourceName);
	}

	public static String getMenuCode(String menuName) {
		Properties properties = (Properties) FacesContextUtils
				.getWebApplicationContext(FacesContext.getCurrentInstance())
				.getBean("menuCodes");
		return (String) properties.get(menuName);
	}
}
